/*stores the amount of plant life at every location in the simulation*/

public class PlantMap
{
  static int[][] pmap;
  
  public static loc GetHabitableLoc()
  {
    //returns a random location that is habitable to for an animal to start in
    return new loc(0,0);
  }
  public static int[][] GetPlantData()
  {
   //Returns the map of plant data to so it can be rendered
    return pmap;
  }
  public static void SetPlantData(int[][] map) {
    pmap = map;
  }
  
  public static int PlantsHere(loc L)
  {
   return pmap[L.x][L.y]; 
    
  }
  public static void eatPlantsHere(loc L,int a)
  {
   pmap[L.x][L.y]-=a; 
   //System.out.println("Plants here are now:"+pmap[L.x][L.y]);
  }
  
  
  public static void UpdatePlants()
  {
    Magic_Eight_Ball.prove_PlantMap_Updates();//This line is here for testing purposes
   int[][] Humid =  HumidMap.GetHumidData();
   int[][] Temp =  TempMap.GetTempData();
   int[][] height = HeightMap.GetHeightMap();
   int fertile =0;
   for(int x=0; x<SimulationConstants.simsize; x++)
   {
    for(int y=0; y<SimulationConstants.simsize; y++) 
    {
      if(height[x][y]>SimulationConstants.sealevel)
      {
      if(Humid[x][y]==0 || Temp[x][y] > 150 || Temp[x][y] < -20)//If stuff is dried out or on fire or deeply frozen
        pmap[x][y]-=20;
      if(Humid[x][y]>10 && Temp[x][y] > 0)//If things are in the fertile range
        pmap[x][y]+=4;
      if(pmap[x][y]<0)// having negative plants is stupid. Also, being able to stockpile intger max worth of plants is foolish too.
         pmap[x][y]=0;
      if(pmap[x][y]>100)
        pmap[x][y]=100;
      if(pmap[x][y]>0)
        fertile++;//debug
    
      }
      else
      {
       if(pmap[x][y]<0)// having negative plants is stupid
         pmap[x][y]=0;
       else
         pmap[x][y]-=5;// kill the under water plants!
        
      }
    }
   }
   //////System.out.println(fertile/(SimulationConstants.simsize.0*SimulationConstants.simsize.0)+"%");
  }
  public static void Initalize()
  {
    pmap = new int[SimulationConstants.simsize][SimulationConstants.simsize];
    for(int x=0; x<SimulationConstants.simsize; x++)
    {
      for(int y=0; y<SimulationConstants.simsize; y++)
      {
        pmap[x][y]=0;
      }
    }
  }
 }
  
